package StreamDemo.demo2;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class test3 {
    public static void main(String[] args){
        //创建集合
        ArrayList<String> manList = new ArrayList<String>();
        manList.add("周润发,24");
        manList.add("成龙,23");
        manList.add("刘德华,22");
        manList.add("吴京,22");
        manList.add("周星驰,24");
        manList.add("李连杰,30");

        ArrayList<String> womanList = new ArrayList<String>();
        womanList.add("林心如,35");
        womanList.add("张曼玉,36");
        womanList.add("林青霞,43");
        womanList.add("柳岩,31");
        womanList.add("林志玲,35");
        womanList.add("王祖贤,33");

        ArrayList<String> getherSet = new ArrayList<>();
        // 获取名字为3个字的男演员,并添加到集合当中
        Stream<String> stream1 = manList.stream().filter(s -> s.split(",")[0].length() == 3).limit(2);
        // 获取姓林的女演员，并添加到集合中
        Stream<String> stream2 = womanList.stream().filter(s -> s.split(",")[0].startsWith("林")).skip(1);
        List<Actor> acList = 
        Stream.concat(stream1,stream2).map(s -> new Actor(s.split(",")[0],Integer.parseInt(s.split(",")[1]))).collect(Collectors.toList());;      
        acList.forEach(s -> System.out.println(s.getName() + "的年龄是： " + s.getAge()));


    }
}
